Skip to content

feat(gql_socket_link): BREAKING CHANGE multiplex websocket connection #491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

agufagit
Copy link
Collaborator

@agufagit agufagit commented May 21, 2025

@knaeckeKami I'm making a breaking change in graphql_transport_ws.dart, please take a look

Streaming operations and single result operations are now multiplexed on a single connection. This means you have to manually resubscribe on subscriptions. On IOS and Android, when you app is in background (lock screen, etc.), all open sockets will be closed to save battery, and your app is freezed, no code from your app will run. Thus there is no way to reconnect a websocket connection when it is broken because no code from your app will run, you have to manually resubscribe on app resume (use WidgetsBindingObserver or related packages). You can use old TransportWebSocketLink client to resubscribe, the underlying socket is newly acquired when you resubscribe.

@knaeckeKami
Copy link
Collaborator

Can you explain the change you did a bit more? From what I understand, there has always been just one WebSocket connection, no? And the code changes mostly add commented out code, I don't see any actual change in behaviour?

@agufagit
Copy link
Collaborator Author

agufagit commented May 23, 2025

I made a new commit. It's actually the result of a series of pull requests that I made. Auto resubscribe may or may not work when app is in foreground because of strange behaviors of web_socket_channel 3.0.3. Auto resubscribe definitely not work when app is in background (lock screen). So for this version, user has to manually resubscribe, I think it would be best to notify users that they need to manually resubscribe. And single-result-operation shouldn't be in for loop, it should complete on NextMessage instead of CompleteMessage, otherwise it might get re-sent.

I made an issue in web_socket_channel dart-lang/http#1775

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants